﻿#region 命名空间

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;
using WinnerCMS.Common;
using WinnerCMS.Model;
using WinnerCMS.BLL;
using WinnerCMS.Model.Attribute;

#endregion

namespace WinnerCMS.WebUI.Admin.Explorer
{
    [Access("258002")]
    public partial class FileEditor : WebFactory.PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Expires = 0;
            Response.CacheControl = "no-cache";


            if (!(IsPostBack))
            {
                try
                {
                    this.txtFile.Text = new FileIO().ReadFile(Request.QueryString["dir"]);
                    Title = Request.QueryString["dir"];
                }
                catch (Exception ex)
                {
                    this.Label1.Text = ex.Message;
                }
            }
        }


        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                new FileIO().WriterFile(Request.QueryString["dir"], this.txtFile.Text);

                MsgBox.Message("保存成功！", this);
            }
            catch
            {
                MsgBox.Message("文件为只读或者没有权限写入。", this);
            }
        }
    }
}